package com.example.coffeeseller_2.model.presenter;

import com.example.coffeeseller_2.model.listenner.IAddFragment;
import com.example.coffeeseller_2.model.model.AddFragment;
import com.example.coffeeseller_2.views.fragments.BasicFragment;
import com.example.coffeeseller_2.views.viewinterface.IAddFragmentView;

/**
 * Created by Administrator on 2018/3/2.
 */

public class AddFragmentPresenter {
    private IAddFragmentView iAddFragmentView;
    private IAddFragment iAddFragment;

    public AddFragmentPresenter(IAddFragmentView iAddFragmentView) {
        this.iAddFragmentView = iAddFragmentView;
        iAddFragment = new AddFragment();
    }


    public void AddFragment() {
        iAddFragment.replaceFragment(iAddFragmentView.getActivity(), iAddFragmentView.getFragment(), iAddFragmentView.getLayoutId());
    }

    public void AddFragment(BasicFragment fragment, int layoutId) {
        iAddFragment.replaceFragment(iAddFragmentView.getActivity(), fragment, layoutId);
    }

    public void removeFragment(BasicFragment fragment) {
        if (fragment != null) {
            iAddFragment.removeFragment(iAddFragmentView.getActivity(), fragment);
        }
    }
}
